nutanixPortal
  .controller('cloudDiskCtrl', function ($scope, $filter, $sce, ngTableParams, tableService, $uibModal){
    //data table
    var data = tableService.data;

    //Sorting
    this.tableSorting = new ngTableParams({
      page: 1,            // show first page
      count: 10,           // count per page
      sorting: {
        name: 'asc'     // initial sorting
      }
    }, {
      total: data.length, // length of data
      getData: function($defer, params) {
        // use build-in angular filter
        var orderedData = params.sorting() ? $filter('orderBy')(data, params.orderBy()) : data;

        $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
      }
    })

    //modal
    $scope.openModal = function(){
      $uibModal.open({
        animation: true,
        templateUrl: '/views/cloudhostModal.html',
        controller: 'cloudhostModalCtrl',
        backdrop: 'static',
        resolve: {
            content: function () {
                return $scope.modalContent;
            }
        }
      });
    };

    this.selected = {
      pattern: 'qcow2'
    };

    //toggle nav right menus
    $scope.isOpen = 0;
    $scope.toggle = function (index) {
      $scope.isOpen = index;
    }
    $scope.status = function (index) {
      return $scope.isOpen == index;
    }
    $scope.navOpen = false;
    $scope.closeRightNav = function () {
      $scope.navOpen = false;
    }
    $scope.toggleRightNav = function () {
      $scope.navOpen = !$scope.navOpen;
    }


  })
  .controller('clouddiskModalCtrl', function ($scope, $uibModalInstance){

    $scope.cancel = function () {
      $uibModalInstance.dismiss('cancel');
    };

    $scope.step = 1;
    function slide(step) {
      $("#slide-wrapper").stop(true,false)
        .animate({"left": -600 * (step - 1) }, 500);
    }
    $scope.goNext = function () {
      
      $scope.step++;
      slide($scope.step);
    };
    $scope.goPre = function () {
      
      $scope.step--;
      slide($scope.step);
    }
    $scope.finish = function () {

      $uibModalInstance.close();
    };

    $scope.data = {
      mirrors: [
        'CentOS 6.4 64bit',
        'CentOS 6.5 64bit',
        'CentOS 6.6 64bit',
        'CentOS 6.7 64bit',
        'CentOS 7.0 64bit',
        'CentOS 7.1 64bit',
        'CentOS 7.2 64bit',
        'Ubuntu 14.04 64bit',
        'Ubuntu 15.04 64bit',
        'Fedora 20 64bit',
        'Fedora 21 64bit',
        'Fedora 22 64bit',
        'Windows Server 2003',
        'Windows Server 2008',
      ],
      cpus: [
        '1v CPU',
        '2v CPU',
        '4v CPU',
        '8v CPU',
        '16v CPU'
      ],
      memories: ['2G', '4G', '8G', '16G'],
      networks: ['public', 'private', 'nxtcloud'],
      filesyses: ['raw', 'qcow2', 'qed', 'vdi', 'vmdk', 'vhd'],
      dbsyses: ['mysql', 'oracle', 'sqlserver'],
      disks: ['256G', '512G', '1T', '2T', '4T']
    };

    $scope.config = {
      sysname: 'administrator',
      mirror: 'CentOS 6.4 64bit',
      cpu: '1v CPU',
      memory: '2G',
      network: 'public',
      user: '',
      pwd: '',
      filesys: 'qcow2',
      dbsys: 'mysql',
      disk: '256G'
    }


});